package Text34;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m=in.nextInt();
        while(m-->0){
            int n = in.nextInt();
            int res = n;
            for (int i = 2; i <= n / i; i++) {
                if (n % i == 0) {
                    res = res / i * (i - 1);
                    while (n % i == 0) {
                        n /= i;
                    }
                }
            }
            if (n > 1) {
                res = res / n * (n - 1);
            }
            System.out.println(res);
        }
    }
}
